package com.example.waterorder.controller;

import com.example.waterorder.service.WechatLoginService;
import com.example.waterorder.tools.Result;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/login")
public class WechatLoginController {
    @Resource
    public WechatLoginService wechatLoginService;

    @Operation(summary = "根据前端的code获取用户openId，并判断是否第一次登录及身份" +
            "0:用户，1：送水员，2：新用户")
    @GetMapping("/getOpenId")
    public Result getWxOpenId(@RequestParam("code") String code){
        return  new Result(true, "登录成功!", wechatLoginService.getUserOpenId(code));
    }

    @GetMapping("")
    public String Test(){
        return wechatLoginService.Test();
    }
}